package com.hnichr.ump.schedule.service.impl;

import com.hnichr.ump.common.schedule.entity.ScheduleDesk;
import com.hnichr.ump.schedule.service.ScheduleDeskService;
import com.mxpioframework.jpa.JpaUtil;
import com.mxpioframework.system.service.impl.BaseServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ScheduleDeskServiceImpl extends BaseServiceImpl<ScheduleDesk> implements ScheduleDeskService {
    @Override
    @Transactional(readOnly = true)
    public ScheduleDesk getByScheduleName(String scheduleName){
        if(StringUtils.isBlank(scheduleName)){
            throw new IllegalArgumentException("scheduleName 为空!!!");
        }
        List<ScheduleDesk> ls = JpaUtil.linq(ScheduleDesk.class).equal("scheduleName",scheduleName).list();
        return CollectionUtils.isEmpty(ls)?null:ls.get(0);
    }
}
